<template>
  <div class="User">
    <el-menu
        mode="horizontal"
        background-color="#545c64"
        text-color="#fff">
      <el-menu-item @click="gouser()">返回 </el-menu-item>
      <el-menu-item @click="unlogin()"style="position: fixed;right: 19px;top: 8px">注销</el-menu-item>
    </el-menu>
    <br><br>
    <el-table :data="data" stripe border style="width: 100%">
      <el-table-column prop="courseName" label="课程名"></el-table-column>
      <el-table-column prop="time" label="上课时间"></el-table-column>
      <el-table-column prop="laboratoryId" label="上课地点"></el-table-column>
      <el-table-column label="操作" prop="courseId">
        <template v-slot="scope">
          <el-button size="mini" type="primary" icon="el-icon-edit" @click="goclass(scope.row.courseId)" >进入该课程</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import global from "../plugins/axios";

export default {
  created() {
    axios.get('/user_course/findCourseByUserId').then(res=>{
      console.log(res);
      this.data=res.data.data;
    })
  },
  data(){
    return{
      data:[]
    }
  },
  methods:{
    goclass(id){
      global.courseId=id;
      this.$router.push('/user/studentgrade');
    },
    gouser() {
      this.$router.push('/user');
    },
    unlogin(){
      axios.post('/user/logout').then(res=> {
        if(res.data.code===10000){
          this.$message.success(res.data.msg);
          this.$router.push('/login');
        }else{
          this.$message.error(res.data.msg);
        }
      })
    }

  }
}
</script>

<style scoped>

</style>